<?php

class Core_Plugin_Stats
{
	public function requestStart()
	{

	}

	public function requestShutdown()
	{
		/**
		 * check if profiling is done.
		 */
		if (!PROFILLING == FALSE)
			return;

		$groups = Profiler::stats();

		$table = Model::getTable('core/stats/profilling');

		$request_id = Agilet::getRequestId();

		foreach ($groups as $group => $mark)
		{
			$data = array(
				'group' => $group,
				'count' => $mark['count'],
				'time' => $mark['time'],
				'memory' => $mark['memory'],
				'request_id' => $request_id,
				'request_time' => START_TIME,
			);
			$table -> insert($data);
		}
	}

}
